home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / COMMUNIC / MRUN211.ZIP / MRUN211A.WAS < prev    next >
Text File  |  1993-05-01  |  23KB  |  728 lines

  1. ;MailRun v2.11:  Part A, Main body of script
  2. ;1992-1993 Gerald P. Sully, all rights reserved.
  3.  
  4. #comment
  5. **************************************************************************
  6. **************************************************************************
  7. * This file serves as "home base" for the rest of the script.
  8. * All other scripts will return to this one if they are
  9. * exited normally.  It initializes MailRun, creates the
  10. * user interface, and then waits for action on the part of the
  11. * user.  If the user executes a mailrun, this section is also
  12. * responsible for taking care of scheduling.
  13. * Elements of the user interface are contained in the header
  14. * file (MRUN211.H).  Menu selections are fielded by parsemenu()
  15. * and the toolbar is controlled by parseobject().  The routines 
  16. * associated with menu items are contained in the header file 
  17. * immediately following parsemenu() and parseobject().  Some of
  18. * these in turn call routines in other script modules through 
  19. * the callscript() procedure.  Where necessary, a FLAG is set to
  20. * inform the target module which routines to execute.  
  21. * The code for the interface is #included in every module of 
  22. * MailRun so that any part of the script may be called from any 
  23. * other part.  Other script modules are called by MRUN211A and 
  24. * MRUN211G (the module responsible for executing the mailrun) 
  25. * using the "execute" command.  When a module is called from
  26. * MRUN211B-F, a "chain" command is used.
  27. **************************************************************************
  28. **************************************************************************
  29. #endcomment
  30.  
  31. #define MRUN211A
  32. #define MRUN211AG
  33. #define MRUN211AB
  34.  
  35. string MainBoxTabs
  36. integer RingInterrupt, AutoRun
  37. integer MailRunMenu, RunningMenu, FileMenu, ConfigMenu, AddMenu
  38. integer DefaultsMenu, ExecuteMenu, HelpMenu, EditMenu
  39.  
  40. #include "mrun211.h"
  41.  
  42. #define HAVEYOUPAID;YOURFIFTEENDOLLARSYET
  43.  
  44. #comment
  45. *********************************************************************
  46. * MAIN()
  47. * Calls checkchild(), initialize(), maketasklist(),
  48. * makemailrunlist(), runmenu(), mrunmenu(), mrunwin(),
  49. * getfirstitem(), helpabout(), parsedialog(), parsekeystate(),
  50. * interfaceon(), executor(), makefullname()
  51. * Main first calls the initialization routines, then puts
  52. * up the main dialog box and waits for user action.
  53. *********************************************************************
  54. #endcomment
  55.  
  56. proc main
  57. string MRunIcons
  58.     checkchild()
  59.     initialize()
  60.     runmenu()
  61.     mrunmenu()
  62.     mrunwin()
  63.     makemailrunlist()
  64.     maketasklist()
  65.     getfirstitem()
  66.     showmenu MailRunMenu
  67.     if AutoRun == 1
  68.         filereset()
  69.         FLAGS |= RUNNING
  70.         GoWait = 1
  71.         PostRun = 3
  72.         pause 2
  73.     else
  74. #ifdef HAVEYOUPAID;YOURFIFTEENDOLLARSYET
  75.         helpabout()
  76. #else
  77.         mailrunbox()
  78. #endif
  79.     endif
  80.     interfaceon()
  81.     MRunIcons = makefullname(MailRunDir, "MRUNICON.DLL")
  82.     when dialog call parsedialog
  83.     while 1
  84.         if FLAGS & RUNNING
  85.             copyfile MRunIcons "C:\MRUNICON.DLL"
  86.             switch $XPIXELS
  87.                 case 1280
  88.                     iconbutton 1 25 0 "" "C:\MRUNICON.DLL" 16 userwin
  89.                 endcase
  90.                 case 1024
  91.                     iconbutton 1 30 0 "" "C:\MRUNICON.DLL" 16 userwin
  92.                 endcase
  93.                 case 800
  94.                     iconbutton 1 40 0 "" "C:\MRUNICON.DLL" 16 userwin
  95.                 endcase
  96.                 default
  97.                     iconbutton 1 50 0 "" "C:\MRUNICON.DLL" 16 userwin
  98.                 endcase
  99.             endswitch
  100.             paint
  101.             delfile "C:\MRUNICON.DLL"
  102.              showmenu RunningMenu
  103.              executor()
  104.             copyfile MRunIcons "C:\MRUNICON.DLL"
  105.             switch $XPIXELS
  106.                 case 1280
  107.                     iconbutton 1 25 0 "" "C:\MRUNICON.DLL" 0 userwin
  108.                 endcase
  109.                 case 1024
  110.                     iconbutton 1 30 0 "" "C:\MRUNICON.DLL" 0 userwin
  111.                 endcase
  112.                 case 800
  113.                     iconbutton 1 40 0 "" "C:\MRUNICON.DLL" 0 userwin
  114.                 endcase
  115.                 default
  116.                     iconbutton 1 50 0 "" "C:\MRUNICON.DLL" 0 userwin
  117.                 endcase
  118.             endswitch
  119.             paint
  120.             delfile "C:\MRUNICON.DLL"
  121.              showmenu MailRunMenu
  122.         endif
  123.     endwhile
  124. endproc
  125.  
  126.  
  127. #comment
  128. *********************************************************************
  129. * INITIALIZE()
  130. * Called by main()
  131. * Calls cleardir(), makemrn(), makefullname(), checkfile()
  132. * Saves system state and initializes global variables.
  133. *********************************************************************
  134. #endcomment
  135.  
  136. proc initialize
  137. string LastRun, env, temp , CleanupFile
  138. string StateCapPath, StateCapFile, StateDnldPath, StateUpldPath
  139. integer StateAutoDL, StateActionBar, StateMetaKeys
  140. integer blank = 0
  141.     ;Create the working directory
  142.     getenv "TEMP" env
  143.     if NULLSTR env
  144.         TempDir = makefullname($PWTASKPATH, "MRUNTEMP")
  145.     else
  146.         TempDir = makefullname(env, "MRUNTEMP")
  147.     endif
  148.     FLAGS = 0
  149.     MailRunIni = makefullname($WINPATH, "MAILRUN.INI")
  150.     profilerd MailRunIni "MailRun" "MailRun" MailRunTrunc
  151.     profilerd MailRunIni "MailRun" "MailRunDir" MailRunDir
  152.     profilerd MailRunIni "MailRun" "AutoRun" AutoRun
  153.  
  154.     ;Save the current state of PCPlus/Win
  155.     fetch autodnld StateAutoDL
  156.     fetch capture path StateCapPath
  157.     fetch capture file StateCapFile
  158.     fetch dnldpath StateDnldPath
  159.     fetch upldpath StateUpldPath
  160.     StateActionBar = $ACTIONBAR
  161.     StateMetaKeys = $METAKEYS
  162.     ;Save the system state in the cleanup file
  163.     cleanupfile = makefullname(TempDir, "CLEANUP.TMP")
  164.     profilewr CleanupFile "Cleanup" "StateAutoDL" StateAutoDL
  165.     profilewr CleanupFile "Cleanup" "StateCapPath" StateCapPath
  166.     profilewr CleanupFile "Cleanup" "StateCapFile" StateCapFile
  167.     profilewr CleanupFile "Cleanup" "StateDnldPath" StateDnldPath
  168.     profilewr CleanupFile "Cleanup" "StateUpldPath" StateupldPath
  169.     profilewr CleanupFile "Cleanup" "StateActionBar" StateActionBar
  170.     profilewr CleanupFile "Cleanup" "StateMetaKeys" StateMetaKeys
  171.  
  172.     ;Change the settings
  173.     set capture path MailRunDir
  174.     set capture query OFF
  175.     set autodnld OFF
  176.     set aspect rangechk OFF
  177.     metakeys OFF
  178.     actionbar OFF
  179.  
  180.     ;If the mailrun in MAILRUN.INI doesn't exist, create it
  181.     if NULLSTR MailRunTrunc
  182.         blank = 1
  183.     else
  184.         LastRun = makefullname(MailRunDir, MailRunTrunc)
  185.     endif
  186.     if !(checkfile(LastRun)) || blank
  187.         temp = makefullname(MailRunDir, "*.MRN")
  188.         findfirst temp
  189.         if FOUND
  190.             MailRunTrunc = $FILENAME
  191.             LastRun = makefullname(MailRunDir, MailRunTrunc)
  192.         else
  193.             MailRunTrunc = "mailrun.mrn"
  194.             MailRunList = "mailrun.mrn"
  195.             makemrn()
  196.             LastRun = MailRun
  197.         endif
  198.     endif
  199.     ;Copy the mailrun to the temp directory
  200.     MailRun = makefullname(TempDir, MailRunTrunc)
  201.     TaskList = makefullname(TempDir, "TASKLIST.TMP")
  202.     copyfile LastRun MailRun
  203.     profilerd MailRun "MailRun" "Archiver" Archiver
  204.     profilerd MailRun "MailRun" "QWKReader" QWKReader
  205.     profilerd MailRun "MailRun" "LogViewer" LogViewer
  206. endproc
  207.  
  208.  
  209. #comment
  210. *********************************************************************
  211. * EXECUTOR()
  212. * Called by main()
  213. * Calls schedulebox(), mailrunbox(), checktime(), fileexit(),
  214. * scheduler(), domailrun(), makefullname(), filereset(),
  215. * maketasklist()
  216. * Executes MRUN211G
  217. * Puts up the MailRun Scheduling box and parses the result.
  218. *********************************************************************
  219. #endcomment
  220.  
  221. proc executor
  222. string HH, MM, SS, temp, LogFile, domailrun
  223. integer Hour, Minute, Second
  224. integer dialogstatus, boxstatus
  225.     domailrun = makefullname(MailRunDir, "MRUN211G")
  226.     findfirst MailRun
  227.     LogFile = $FNAME
  228.     strcat LogFile ".CAP"
  229.     if AppendLog == 0
  230.         ;if user does not want to append to existing log file
  231.         temp = makefullname(MailRunDir, LogFile)
  232.         delfile temp
  233.     endif
  234.     set capture file LogFile
  235.     profilerd MailRun "MailRun" "RingInterrupt" RingInterrupt
  236.     if AutoRun == 0
  237.         profilerd MailRun "MailRun" "ExecTime" ExecTime
  238.         profilerd MailRun "MailRun" "PostRun" PostRun
  239.         profilerd MailRun "MailRun" "GoWait" GoWait
  240.         schedulebox()
  241.         if GoWait == 1 
  242.             disable CTRL 230
  243.         endif
  244.     endif
  245.     ;boxstatus indicates whether or not mailrunbox is showing
  246.     boxstatus = 0
  247.     ;turn off parsedialog() for parsing contols
  248.     clearwhen dialog
  249.     while (FLAGS & RUNNING) && (AutoRun == 0)
  250.         dialogstatus = $DIALOG
  251.         switch dialogstatus
  252.             case 1
  253.                 ;User selected "Cancel"
  254.                 FLAGS &= IDLE
  255.                 mailrunbox()
  256.                 boxstatus = 1
  257.                 ;turn b